In Svelte, the export let syntax is used to declare props in a component. This allows data to be passed from a parent component to a child component, making the child component dynamic and reusable.
To receive values from a parent component.
To make components customizable and reusable.
To define default values for props directly in the child component.
To establish one-way data flow, meaning changes in the parent update the child, but not vice versa.
Here, label is a prop that can be set by the parent component. If no value is provided, the default value 'Click Me' will be used.
The App.svelte file passes values to the Button component using the label prop.
If a parent does not provide a value for a prop, the default value specified in the export let declaration will be used automatically.
export let declares a prop that a parent can set.
Props are one-way, meaning updates flow from parent to child.
Default values make components safer and easier to use.
If no value is passed, the default value remains in effect.